<?php

/**
 * @Author: Wang Chunsheng 2192138785@qq.com
 * @Date:   2020-03-02 17:17:15
 * @Last Modified by:   Wang Chunsheng 2192138785@qq.com
 * @Last Modified time: 2020-03-03 16:40:26
 */


use common\models\DdGoods;
use yii\helpers\Html;
use common\widgets\MyActiveForm;
use richardfan\widget\JSRegister;
use yii\helpers\Url;

/* @var $this yii\web\View */
/* @var $model common\models\DdGoods */
/* @var $form yii\widgets\MyActiveForm */
?>
<?php if ($op == 'update') : ?>
    <?php foreach ($specitem as $key => $specitem) : ?>
        <div class="alert alert-new spec_item" style='width:100%;' id='spec_<?php echo $key ?>'>
            <input name="spec_id[]" type="hidden" class="form-control spec_id" value="<?php echo $key ?>" />
            <div class="form-group">
                <label class="col-xs-12 col-sm-2 col-md-2 col-lg-1 control-label"> 规格名</label>
                <div class="col-xs-12 col-sm-8 col-lg-9">
                    <input name="spec_title[<?php echo $key ?>]" type="text" class="form-control  spec_title" value="<?php echo $specv[$key]['spec_name'] ?>" placeholder="(比如: 颜色)" />
                </div>
            </div>
            <div class="form-group">
                <label class="col-xs-12 col-sm-2 col-md-2 col-lg-1 control-label">规格项</label>
                <div class="col-xs-12 col-sm-8 col-lg-9">
                    <div id='spec_item_<?php echo $key ?>' class='spec_item_items'>

                        <?php foreach ($specitem as $specid =>  $items) : ?>
                            <?php echo $this->renderAjax("spec_items", [
                                'model' => $model,
                                'form' => $form,
                                'items' => $items,
                                'specitem' => $specitem,
                                'specid' => $specid,
                                'key' => $key,
                                'specv' => $specv,
                                'spec_item_thumbs' => $spec_item_thumbs,
                                'spec_item_shows' => $spec_item_shows,


                            ]);
                            ?>
                        <?php endforeach; ?>
                    </div>
                </div>
                <div class="col-xs-12 col-sm-8 col-lg-9">
                    <label class="col-xs-12 col-sm-2 col-md-2 col-lg-1 control-label">&nbsp;&nbsp;&nbsp;</label>
                    <div class="col-xs-12 col-sm-8 col-lg-9">
                        <a href="javascript:;" id="add-specitem-<?php echo $key ?>" data-specid='<?php echo $key ?>' class='btn btn-info add-specitem'>
                            <i class="fa fa-plus"></i> 添加规格项
                        </a>
                        <a href="javascript:void(0);" class='btn btn-danger removeSpec' id='removeSpec' data-specid='<?php echo $key ?>'>
                            <i class="fa fa-plus"></i> 删除规格
                        </a>
                    </div>
                </div>
            </div>
        </div>
    <?php endforeach; ?>

<?php else : ?>

    <div class="alert alert-new spec_item" style='width:100%;' id='spec_<?php echo $spec['id'] ?>'>
        <input name="spec_id[]" type="hidden" class="form-control spec_id" value="<?php echo $spec['id'] ?>" />
        <div class="form-group">
            <label class="col-xs-12 col-sm-2 col-md-2 col-lg-1 control-label"> 规格名</label>
            <div class="col-xs-12 col-sm-8 col-lg-9">
                <input name="spec_title[<?php echo $spec['id'] ?>]" type="text" class="form-control  spec_title" value="<?php echo $spec['title'] ?>" placeholder="(比如: 颜色)" />
            </div>
        </div>
        <div class="form-group">
            <label class="col-xs-12 col-sm-2 col-md-2 col-lg-1 control-label">规格项</label>
            <div class="col-xs-12 col-sm-8 col-lg-9">
                <div id='spec_item_<?php echo $spec['id'] ?>' class='spec_item_items'>

                    <?php foreach ($specitem as  $items) : ?>
                        <?php echo $this->renderAjax("spec_items", [
                            'model' => $model,
                            'form' => $form,
                            'items' => $items,
                            'specitem' => $specitem,
                            'spec' => $spec,

                        ]);
                        ?>
                    <?php endforeach; ?>
                </div>
            </div>
            <div class="col-xs-12 col-sm-8 col-lg-9">
                <label class="col-xs-12 col-sm-2 col-md-2 col-lg-1 control-label">&nbsp;&nbsp;&nbsp;</label>
                <div class="col-xs-12 col-sm-8 col-lg-9">
                    <a href="javascript:;" id="add-specitem-<?php echo $spec['id'] ?>" data-specid='<?php echo $spec['id'] ?>' class='btn btn-info add-specitem'>
                        <i class="fa fa-plus"></i> 添加规格项
                    </a>
                    <a href="javascript:void(0);" class='btn btn-danger removeSpec' id='removeSpec' data-specid='<?php echo $spec['id'] ?>'>
                        <i class="fa fa-plus"></i> 删除规格
                    </a>
                </div>
            </div>
        </div>
    </div>
<?php endif; ?>